/**
 * Created by dell on 2017/2/23.
 */

$(document).ready(function () {
    // 随机选择头部和尾部的背景色
    var colorArray = [
        "#000",
        "#6b7536",
        "#5f6c1c",
        "#014b88",
        "#283989",
        "#009188",
        "#903E78"
    ];
    var colorArrayLen = colorArray.length;
    var selectedColor = colorArray[Math.floor(Math.random()*colorArrayLen)];
    $('.header,.footer').css({"backgroundColor":selectedColor});


    var dWidth = $(window).height();
    var cHeight = $('#content').height();

    // 屏幕小于700，
    if((dWidth<=750 && cHeight>=500 && cHeight <680) || (cHeight >=680) ) {
        if(cHeight >=500){
            $("div.footer").css({
                "position": "relative",
                "marginTop": "20px"
            });
        }

    }else{
        $(".header a#logo").css({
            "height": "100px",
            "background-size": "auto"
        });
        $("div.footer").css({
            "position": "absolute",
            "marginTop": "0px",
            "bottom":"0px",
            "left":"0px"
        });
    }
    $(window).resize(function(){

        var dWidth = $(window).height();
        var cHeight = $('#content').height();
        // 屏幕小于700,内容高度大于600，
        if((dWidth<=750 && cHeight>=500 && cHeight <680) || (cHeight >=680)) {
            if(cHeight >=500){
                $("div.footer").css({
                    "position": "relative",
                    "marginTop": "20px"
                });
            }

        }else{

            $(".header a#logo").css({
                "height": "100px",
                "background-size": "auto"
            });
            $("div.footer").css({
                "position": "absolute",
                "marginTop": "0px",
                "bottom":"0px",
                "left":"0px"
            });
        }


    });

});